<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>场地信息管理</title>
    <link rel="stylesheet" type="text/css" href="/site_jquery-easyui-1.3.3/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/site_jquery-easyui-1.3.3/themes/icon.css">
    <script type="text/javascript" src="/site_jquery-easyui-1.3.3/jquery.min.js"></script>
    <script type="text/javascript" src="/site_jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/site_jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
        var url;
        function search(){
            $("#dg").datagrid('load',{
                "name":$("#name").combobox("getValue"),
                "position":$("#position").combobox("getValue"),
                "purpose":$("#purpose").combobox("getValue"),
                "status":$("#status").combobox("getValue")
            });
        };


        function openAddDialog(){
            $("#dlg").dialog("open").dialog("setTitle","登记新场地信息");
            url="/siteInformation/addSiteInfo";
        };


        function saveSite(){
            $("#fm").form("submit",{
                url:url,
                success:function(result){
                    var result=eval('('+result+')');
                    if(result.success){
                        $.messager.alert("系统提示","登记成功");
                        closeDialog();
                        $("#dg").datagrid("reload");
                    }else{
                        $.messager.alert("系统提示","登记失败");
                        return;
                    }
                }
            });
        };

        function openlookDialog(){
            var selectedRows=$("#dg").datagrid('getSelections');
            if(selectedRows.length!=1){
                $.messager.alert("系统提示","请选择一条要查看的数据！");
                return;
            }
            var row=selectedRows[0];
            $("#dlg").dialog("open").dialog("setTitle","查看场地信息明细");
            $('#fm').form('load',row);
            $('#btn').linkbutton('disable');
            $('#siteStatus').combo('readonly', true);
        }

        function openModifyDialog(){

            var selectedRows=$("#dg").datagrid('getSelections');
            if(selectedRows.length!=1){
                $.messager.alert("系统提示","请选择一条要变更的数据！");
                return;
            }
            var row=selectedRows[0];

            $("#dlg").dialog("open").dialog("setTitle","修改场地信息明细");
            $('#fm').form('load',row);

            url="/siteInformation/modifySiteInfo";
        }

        function closeDialog(){
            $("#dlg").dialog("close");

            $("#fm").form("clear");
            $('#btn').linkbutton('enable');
            $('#siteStatus').combo('readonly', false);

        };
        

        function openWeixiuDialog() {
            var selectedRows=$("#dg").datagrid('getSelections');
            if(selectedRows.length!=1){
                $.messager.alert("系统提示","请选择一条要检修的数据！");
                return;
            }
            var row=selectedRows[0];
            if (row.status=="正在维修"||row.status=="报废"){
                $.messager.alert("系统提示","请选择一条要检修的数据！");
                return;
            }
            $('#fm2').form('load',row);
            $("#dlg2").dialog("open").dialog("setTitle","填写维修场地信息");

            
        };
        function closeDialog2() {
            $("#dlg2").dialog("close");
            $("#fm2").form("clear");

        };
        function saveWeixiu() {
            $("#fm2").form("submit",{
                url:"/siteMaintenance/addSiteMaintenance",
                success:function(result){
                    var result=eval('('+result+')');
                    if(result.success){
                        $.messager.alert("系统提示","登记成功");
                        closeDialog2();
                        $("#dg").datagrid("reload");
                    }else{
                        $.messager.alert("系统提示","登记失败");
                        return;
                    }
                }
            });
        };

    </script>
</head>
<body style="margin:1px;">
<table id="dg" title="场地信息管理" class="easyui-datagrid"
       fitColumns="true" pagination="true" rownumbers="true" singleSelect="true"
       url="/siteInformation/findAllSiteInformation" fit="true" toolbar="#tb">
    <thead>
    <tr>
        <!--
                private Integer siteId;
                private String name;
                private String position;
                private String purpose;
                private String status;
                private Double price;
                private Date changeDate;
                private Integer adminId;
                private String detail;
        -->

        <th field="siteId" width="50" align="center">编号</th>
        <th field="name" width="60" align="center">场地名称</th>
        <th field="position" width="90" align="center">场地位置</th>
        <th field="purpose" width="85" align="center" >场地用途</th>
        <th field="detail" width="100" align="center" hidden="true">详细说明</th>
        <th field="status" width="80" align="center">使用情况</th>
        <th field="price" width="60" align="center">价格</th>
        <th field="adminName" width="60" align="center">修改人</th>
        <th field="changeDate" width="60" align="center">修改时间</th>

    </tr>
    </thead>
</table>
<div id="tb">
    <div>
        <a href="javascript:openAddDialog()" class="easyui-linkbutton" iconCls="icon-add" plain="true">登记新场地</a>
        <a href="javascript:openModifyDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">修改场地信息</a>
        <a href="javascript:openlookDialog()" class="easyui-linkbutton" iconCls="icon-tip" plain="true">查看详细</a>
        <a href="javascript:openWeixiuDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">场地检修</a>

    </div>
    <div>
        &nbsp;场地名称：&nbsp;<input class="easyui-combobox" name="name" id="name" style="width: 148px;"
                                data-options="
									url:'/siteInformation/findName',
									valueField:'id',
									textField:'text',
									panelHeight:'auto'">
        &nbsp;场地位置：&nbsp;<input class="easyui-combobox" name="position" id="position" style="width: 148px;"
                                data-options="
									url:'/siteInformation/findPosition',
									valueField:'id',
									textField:'text',
									panelHeight:'auto'">
        &nbsp;场地用途：&nbsp;<input class="easyui-combobox" name="purpose" id="purpose" style="width: 148px;"
                                data-options="
                                    url:'/siteInformation/findPurpose',
									valueField:'id',
									textField:'text',
									panelHeight:'auto'">
        &nbsp;使用情况：&nbsp;<input class="easyui-combobox" name="status" id="status" style="width: 135px;"
                                data-options="
                                    url:'/siteInformation/findStatus',
									valueField:'id',
									textField:'text',
									panelHeight:'auto',

                                    ">

        <a href="javascript:search()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
    </div>
</div>

<div id="dlg" class="easyui-dialog" style="width: 680px;height:350px;"
     closed="true"  closable="false" buttons="#dlg-buttons">
    <form id="fm"  enctype="multipart/form-data"  method="post">
        <table >
            <!--
               private Integer siteId;
               private String name;
               private String position;
               private String purpose;
               private String status;
               private Double price;
               private Date changeDate;
               private Integer adminId;
               private String detail;
       -->
            <tr><td><input name="siteId" id="siteId" type="hidden"></td></tr>
            <tr>
                <td>场地名称：</td>
                <td>
                    <input class="easyui-textbox" name="name" id="siteName"></input>
                </td>
            </tr>

            <tr>
                <td>位置：</td>
                <td>
                    <input class="easyui-textbox" name="position" id="sitePosition"></input></td>
                </td>
            </tr>
            <tr>
                <td>用途：</td>
                <td>
                    <input class="easyui-textbox" name="purpose" id="sitePurpose"></input></td>
                </td>
            </tr>
            <tr>
                <td>价格：</td>
                <td><input type="text" class="easyui-numberbox" name="price" id="sitePrice" value="100" data-options="min:0,precision:2"></input>
                </td>
            </tr>
            <tr>
                <td>场地状态：</td>
                <td>
                    <select id="siteStatus" class="easyui-combobox" name="status" panelHeight="auto" style="width:147px;">
                        <option value="可租借" selected>可租借</option>
                        <!--<option value="维修">维修</option>-->
                        <option value="已租借">已租借</option>
                       <!-- <option value="报废">报废</option>-->
                        <option value="特殊用途">特殊用途</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td valign="top">场地详细描述：</td>
                <td colspan="8">
                    <textarea rows="5" cols="60" id="SiteDetail" name="detail"></textarea>
                </td>
            </tr>

        </table>
    </form>
</div>

<div id="dlg-buttons">
    <a href="javascript: saveSite()" id="btn" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
    <a href="javascript: closeDialog()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>

<div id="dlg2" class="easyui-dialog" style="width: 680px;height:350px;"
     closed="true"  closable="false" buttons="#dlg-buttons2">
    <form id="fm2"  enctype="multipart/form-data"  method="post">
        <table >
            <tr><td><input name="siteId"  type="hidden"></td></tr>
            <tr>
                <td valign="top">维修描述：</td>
                <td colspan="8">
                    <textarea rows="5" cols="60" id="maintenanceMode" name="maintenanceMode"></textarea>
                </td>
            </tr>
        </table>
    </form>
</div>

<div id="dlg-buttons2">
    <a href="javascript: saveWeixiu()" id="btn2" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
    <a href="javascript: closeDialog2()" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>
</body>
</html>